<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
	<style type="text/css">
	.item{
		width: 115px;
		display: inline-block;
		margin-left: 5px;
	}
    </style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
		<table width="100%" border="0">
			<tr>
			    <td style="width:30%;">
			      <span class="item">下单时间（大于）：</span>
			      <input id="start_time" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false" /> 
				</td>
			    <td style="width:30%;">
			      <span class="item">下单时间（小于）：</span>
				  <input id="end_time" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false" /> 
				</td>
				<td style="width:30%;">
			      <span class="item">媒体：</span>
			      <input id="media" emptyText="请选择..." showNullItem="true" nullItemText="全部" class="mini-combobox" url="pro_sales_stat_find_media.do" style="width:160px;" textField="name" valueField="id" />
			    </td>
			 </tr>
			<tr>
			    <td style="width:30%;">
			      <span class="item">客服组：</span>
			      <input id="cur_ser_group" emptyText="请选择..." showNullItem="true" nullItemText="全部" class="mini-combobox" style="width:160px;" textField="name" valueField="id" 
        				onvaluechanged="onDeptChanged" url="pro_sales_stat_find_group.do" />
			    </td>
			    <td style="width:30%;">
			      <span class="item">客服代表：</span>
			      <input id="cur_ser" emptyText="请先选择客服组" class="mini-combobox" style="width:160px;" textField="name" valueField="id"/>
			    </td>
			    <td style="width:30%;">
			      <span class="item">编号（精确）：</span>
			      <input id="orders_num" emptyText="请输入编号" class="mini-textbox" onenter="onKeyEnter" style="width:160px;"/>
			    </td>
			    <td style="display: inline-block;"><a class="mini-button" iconCls="icon-search" onclick="search()">查询</a> </td>
			 </tr>
		</table>          
	</div>
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	    <table style="width:100%;">
	        <tr>
	            <td style="width:100%;">
	            	<sec:authorize url='/orders_ride_pin_sta_expots.do'>
                  	<a class="mini-button" iconCls="icon-ok" onclick="exportAllData()">导出所有</a>
                  	</sec:authorize>
                  	<span style="color: #f00;">（注：数据不包含正在输入的、无效的、取消的订单，不统计赠品）</span>
            	</td>
	        </tr>
	    </table>           
	</div>
	<div class="mini-fit" >
	<div id="datagrid1" class="mini-datagrid" idField="id" allowCellWrap="true" pageSize="20" url="orders_ride_pin_sta_view.do" style="width:100%;height:100%;" >
		<div property="columns">
			<div field="ordersNum" width="100" headerAlign="center" align="center">订单号</div>
			<div field="ordersTime" width="100" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">下单时间</div>
			<div field="productDetail" width="100" headerAlign="center" align="center">产品明细</div>
			<div field="productCount" width="100" headerAlign="center" align="center">产品总数</div>
			<div field="mainProduct" width="100" headerAlign="center" align="center">主要产品数</div>
			<div field="ridePinProduct" width="100" headerAlign="center" align="center">搭销产品数</div>
			<div field="mediaName" width="100" headerAlign="center" align="center">媒体</div>
		</div>
	</div>
	</div>

<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid1");

grid.load();

var curSerGroup = mini.get("cur_ser_group");
var curSer = mini.get("cur_ser");
function onDeptChanged(e) {
    var id = curSerGroup.getValue();
    curSer.setValue("");
    var url = "pro_sales_stat_find_cur_ser.do?groupId=" + id;
    curSer.setUrl(url);
}

function search() {
    var startTime = mini.get("start_time").getFormValue();
    var endTime = mini.get("end_time").getFormValue();
    var media = mini.get("media").getValue();
    var ordersNum = mini.get("orders_num").getValue();
    
    grid.load({ 
    	startTime: startTime,
    	endTime: endTime,
    	mediaId: media,
    	cusSerId: curSer.getValue(),
    	ordersNum: ordersNum
    });
}

function onKeyEnter(e) {
    search();
}	

//导出全部
function exportAllData(){
	var curSer = mini.get("cur_ser").getValue();
	var startTime = mini.get("start_time").getFormValue();
    var endTime = mini.get("end_time").getFormValue();
    var media = mini.get("media").getValue();
    var ordersNum = mini.get("orders_num").getValue();
	window.location.href="orders_ride_pin_sta_expots.do?stime="+startTime+"&etime="+endTime+"&mediaId="+media+"&cusSerId="+curSer+"&ordersNum="; 
}
</script>
</body>
</html>